﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DesignPatterns
{
    public abstract class StatePattern
    {
        public StateContext _stateContext;

        public void SetContext(StateContext stateContext)
        {
            this._stateContext = stateContext;
        }

        public abstract void DoOne();

        public abstract void DoTwo();
    }

    public class OneState : StatePattern
    {


        public override void DoOne()
        {
            Console.WriteLine("111-111 ...");
            base._stateContext.SetStateContext(new TwoState());

        }

        public override void DoTwo()
        {
            Console.WriteLine("111-222 ...");

        }
    }

    public class TwoState : StatePattern
    {


        public override void DoOne()
        {
            Console.WriteLine("222-111 ...");
        }

        public override void DoTwo()
        {
            Console.WriteLine("222-222 ...");

        }
    }

    public class StateContext
    {
        private StatePattern _statePattern;

        public void SetStateContext(StatePattern statePattern)
        {
            _statePattern = statePattern;
        }


        public void RequestOne()
        {
            _statePattern.DoOne();
            _statePattern.DoTwo();

        }
    }
}
